home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc1 / fscode.lha / Specs.Doc < prev   
Text File  |  1996-05-11  |  4KB  |  90 lines

  1.              FSCODE FILE FORMAT SPECIFICATIONS
  2.                 by Flavio Stanchina
  3.  
  4. Single-part FScoded files begin with the following line:
  5.  
  6.     template: !start <file name>
  7.     example : !start Nobody's fault but mine
  8.  
  9. Multi-part FScoded files begin with the following line:
  10.  
  11.     template: !mstrt <part>/<parts> <file name>
  12.     example : !mstrt 42/666 In my time of dying
  13.  
  14. <file name> is everything that follows the space after the "!start" keyword
  15. or the part counters, until the end of the line, spaces included; it is
  16. recommended to replace spaces with underlines on machines incapable of
  17. using spaces in file names.
  18.  
  19. <part> and <parts> are decimal numbers: <parts> is the total number of
  20. blocks this file was split into, and <part> can range from 1 to <parts>;
  21. the two numbers can be separated by any non-numeric character.
  22.  
  23. Each block of a multi-encoded file can be made of an arbitrary number of
  24. lines.
  25.  
  26. Then follows the encoded data; each group of 5 characters represents a
  27. longword of the original data converted in base 85, using the ASCII
  28. characters from 42 to 126 (from '*' to '~') as digits, most significant
  29. digit first, and padded with "zeros" (remember that our "zero" is really
  30. '*'). Encoded data can be arbitrarily interspersed with blanks (spaces,
  31. line feeds, etc), that are to be skipped when reading in the data for
  32. decoding.
  33.  
  34. You might have noticed that not all files are longword-aligned in their
  35. lenght: for this reason, a group of five characters can contain the
  36. character '#' (ASCII 35) in it's one to three most significant digits,
  37. which means that one to three of the most significant bytes in the decoded
  38. longword are to be considered empty and are not to be written to the output
  39. file when decoding. For example, a file of length 2 would look like this:
  40.  
  41.     !start 42
  42.     ##+r;
  43.     !end 2 A8D1BE1F
  44.  
  45. This means that you must decode this longword of data as if it was only 3
  46. characters long (this is equivalent to taking the #'s as *'s, i.e zeros)
  47. and write out only the two least significant bytes. Probably you can manage
  48. to understand all of this by looking at what happens in the Decode()
  49. function when a '#' is found.
  50.  
  51. The current implementation allows a partially filled longword to appear
  52. anywhere in the file, however it is not recommended to do so without good
  53. reason because it is a waste of space.
  54.  
  55. Decoding stops when the ending line is found. It has the form
  56.  
  57.     template: !end <size> <CRC>
  58.     example : !end 416 2020E6B
  59.  
  60. <size> is decimal and <CRC> is hexadecimal. <size> is the size in bytes of
  61. the original file. <CRC> is a 32-bit CRC calculated using the polynomial
  62. 0x04C11DB7 (AUTODIN II, Ethernet, & FDDI); the algorithm has been taken
  63. from the comp.compression FAQ list of october 1992, but has been changed to
  64. NOT complement the resulting CRC for simpler implementation.
  65.  
  66. In multi-part mode the size and CRC values are correct for all the parts up
  67. to this one. This allows for a correctness check on every part.
  68.  
  69. Control lines ("!start", "!mstrt" and "!end") must start on the first
  70. column; the '!' character has been chosen as the introducer of the control
  71. lines because it is not used in the encoded data, thus provides a reliable
  72. way to distinguish the two kinds of input.
  73.  
  74. The "start", "mstrt" and "end" keywords can be lowercase, uppercase or
  75. mixed case, but it is recommended to write them out as lowercase for
  76. consistency.
  77.  
  78. Some notes on the encoding method. 85^5 is slightly greater than 2^32; this
  79. is the best compromise between simplicity and speed on one side, and
  80. efficiency on the other, if we want to encode all possible 256 byte values
  81. to the limited set of 95 ASCII characters allowed over the various nets.
  82.  
  83. Encoding more bits at a time would require quite complex algorythms,
  84. because most computers and most programming languages (C, in particular) do
  85. not have arithmetic instructions for handling numbers wider than 32 bits;
  86. on the other side, to increase efficiency over this method you should
  87. encode as much as 32 bytes at a time into 39 characters, gaining only one
  88. character over 40. Definitely too much trouble.
  89.  
  90.